Lets in this tutorial I am going to share you the script through which you can ping multiple IP Addresses using Powershell and text file.
Do I ping multiple IP addresses at once.
Is it really possible to ping multiple IP Address / Host names at once ?
How to ping multiple IP and make a output into text file?
Multiple host names / IP address ping & output automatically?
How to ping all IP addresses under my Lan connection.
Powershell scripting for ping list of IP Address and output as text file?
Once you done with text file & IP addresses, now you need to open
Windows Powershell ISE in your system. To open the application all you need to
press [windows] button & in the search box just type "Powershell
ISE" & hit Enter.
Yessss! We can proceed further now.
Now,
under Powershell ISE you need to copy paste the below lines, followed by press
the Run Script button. But before hit the Run button paste my below
codes:-
$names=Get-Content "Y:\ip.txt"
foreach ($name in $names){
if(Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue){
Write-Host "$name is UP" -ForegroundColor Green
$Output+="$name is UP"+"`n"
}
else{
Write-Host "$name is DOWN" -ForegroundColor Red
$Output+="$name is DOWN"+"`n"
}
}
$Output | Out-File "Y:\pingtest.txt"
Start-Sleep -s 10
As you can see here in left side, under powershell ISE application you can see the result of ping test of multiple IP, side by side on the other image you can see in my computer hard disk "Y" Drive one file will create namely "pingtest.txt" [you can change the output file name, by editing the scripting code.] under this pingtest.txt file the output will be generate of a IP ping test.
You can save the script file in your system, through which you can easily run the ping test of the IP addresses with a single click. For this you need to save the script, and here is the steps you need to follow:-
Step 1: Right after copy & paste the code hit the "File" button followed by click on "Save as" button.
Step 2: Choose the destination where you want to save the script file, in my case I am going to save in my "Desktop" which is really convenient for all of us.Step 3 :
Give a filename, whatever you want and click on save button.
Good news buddy!! You have created the script file for your future usage.
Next time if you want to check ping status of IP Addresses / Host names you really do not need to copy paste my code. All you have to simply right click on the script file & choose "Run with Poweshell" option.
With your single click the script start working on it & you'll get the output both in powershell and the text file.
Comments
Post a Comment
If you like my post please don't forget to checkout my Youtube channel!! Also let me know, is this post helpful or not. Do share | like | comment in my post. Thanks for watching, will see you in the next blog.